Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): override setup_future_usage filed to on_session based on merchant config #5195

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

ShankarSinghC
Copy link
Contributor

@ShankarSinghC ShankarSinghC commented Jul 3, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This is the use case where in which we need if the setup_future_usage is set to off_session in the payment method needs to be just saved at hyperswitch and not at connector. This is fix to override it during the pre-routing as well.

skip_saving_wallet_at_connector_<merchant_id> is the config which takes vector of payment method type as the value. When this config is set, the setup_future_usage is overridden to on_session by which mandates won't be created at the connector's end.

curl --location 'localhost:8080/configs/' \
--header 'api-key: test_admin' \
--header 'Content-Type: application/json' \
--data '{
    "key": "skip_saving_wallet_at_connector_merchant_1718351667",
    "value": "[\"apple_pay\"]"
}'

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

-> Create merchant connector account
-> Make a CIT with off_session and customer acceptance

{
    "amount": 800,
    "currency": "USD",
    "confirm": true,
    "amount_to_capture": 800,
    "customer_id": "{{$timestamp}}",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data":"\==",
                "payment_method": {
                    "display_name": "Visa 0326",
                    "network": "Mastercard",
                    "type": "debit"
                },
                "transaction_identifier": "55CC32D7BF7890B9064433F15B9F23F849CF84AFD01E4E65DD8ADE306300E9D8"
            }
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    }
}
image

-> Create confirm false

{
    "amount": 2000,
    "currency": "USD",
    "confirm": false,
    "amount_to_capture": 2000,
    "customer_id": "1720081192",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "[email protected]",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "setup_future_usage": "off_session"
}
image

-> Confirm with payment data without customer acceptance

{
    "client_secret": "pay_Fgkr31SdjHPZJhq2ImD8_secret_SaWA7AtdvD467lCSnApQ",
    "payment_type": "new_mandate",
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": "==",
                "payment_method": {
                    "display_name": "Visa 0326",
                    "network": "Mastercard",
                    "type": "debit"
                },
                "transaction_identifier": "55CC32D7BF7890B9064433F15B9F23F849CF84AFD01E4E65DD8ADE306300E9D8"
            }
        }
    }
}

-> Now when listed the last used should be updated

curl --location 'http://localhost:8080/customers/1720081349/payment_methods' \
--header 'Accept: application/json' \
--header 'api-key: aaa'

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@ShankarSinghC ShankarSinghC added A-core Area: Core flows C-bug Category: Bug A-payments Area: payments labels Jul 3, 2024
@ShankarSinghC ShankarSinghC self-assigned this Jul 3, 2024
@ShankarSinghC ShankarSinghC requested a review from a team as a code owner July 3, 2024 18:05
@ShankarSinghC ShankarSinghC force-pushed the fix/apple_pay/over_ride_setup_future_usage branch from b1ab927 to 8e898f2 Compare July 3, 2024 19:08
@preetamrevankar preetamrevankar added this pull request to the merge queue Jul 4, 2024
Merged via the queue into main with commit 52abda9 Jul 4, 2024
15 checks passed
@preetamrevankar preetamrevankar deleted the fix/apple_pay/over_ride_setup_future_usage branch July 4, 2024 10:49
pixincreate added a commit that referenced this pull request Jul 5, 2024
…ify-cypress

* 'main' of github.com:juspay/hyperswitch: (22 commits)
  refactor: Adding millisecond to Kafka timestamp (#5202)
  chore(version): 2024.07.05.0
  fix(user_auth_method): make id option in auth select (#5213)
  Docs: Updated API - ref for payments (#5172)
  feat(core): add merchant order reference id (#5197)
  feat(analytics): Refund status serialization issue for ckh analytics (#5199)
  fix(router): `override setup_future_usage` filed to on_session based on merchant config (#5195)
  feat(cypress): make tests forcefully skippable (#5176)
  feat(core): Added integrity framework for Authorize and Sync flow with connector as Stripe (#5109)
  ci(cypress): Update card number for adyen and status for paypal (#5192)
  refactor(cypress): error handling and add sync refunds in places where missing (#5128)
  feat(analytics): FRM Analytics (#4880)
  chore(version): 2024.07.04.0
  feat(pm_auth): Added balance check for PM auth bank account (#5054)
  refactor(payment_methods): add appropriate missing logs (#5190)
  refactor(migrations): add commands to make file to run migrations for api v2 (#5169)
  chore(version): 2024.07.03.0
  fix(event): Updated the ApiEventMetric (#5126)
  feat(router): add refunds manual-update api (#5094)
  refactor(payment_link): logs payment links logs coverage (#4918)
  ...
Narayanbhat166 pushed a commit that referenced this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows A-payments Area: payments C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

override setup_future_usage filed to on_session based on merchant config
4 participants